package cn.iocoder.yudao.module.system.api.permission;

import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.api.permission.dto.RoleRespDTO;
import cn.iocoder.yudao.module.system.service.permission.PermissionService;
import cn.iocoder.yudao.module.system.service.permission.RoleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/**
 * 角色 API 实现类
 *
 * @author 航盛
 */
@Service
public class RoleApiImpl implements RoleApi {

    @Resource
    private RoleService roleService;
    @Resource
    private PermissionService permissionService;

    @Override
    public void validRoleList(Collection<Long> ids) {
        roleService.validateRoleList(ids);
    }

    @Override
    public List<RoleRespDTO> getRoleListFromCache(Long userId) {
        return BeanUtils.toBean(roleService.getRoleListFromCache(permissionService.getUserRoleIdListByUserId(userId)), RoleRespDTO.class);
    }


}
